package com.akai.validation;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import com.akai.anno.State;

public class StateValidation  implements ConstraintValidator<State,String> {
    /**
     *
     * @param s 注解的参数
     * @param constraintValidatorContext
     * @return 若返回flase 则表示校验失败 若返回true 则表示校验成功
     */
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        //提供校验规则
        if (s == null){
            return false;
        }
        if (s.equals("已发布") || s.equals("草稿")){
            return true;
        }
        return false;
    }
}
